AmCharts.AmPieChart=AmCharts.Class({inherits:AmCharts.AmSlicedChart,construct:function(t){this.type="pie";AmCharts.AmPieChart.base.construct.call(this,t);this.cname="AmPieChart";this.pieBrightnessStep=30;this.minRadius=10;this.depth3D=0;this.startAngle=90;this.angle=this.innerRadius=0;this.startRadius="500%";this.pullOutRadius="20%";this.labelRadius=20;this.labelText="[[title]]: [[percents]]%";this.balloonText="[[title]]: [[percents]]% ([[value]])\n[[description]]";this.previousScale=1;AmCharts.applyTheme(this,t,this.cname)},drawChart:function(){AmCharts.AmPieChart.base.drawChart.call(this);var t=this.chartData;if(AmCharts.ifArray(t)){if(0<this.realWidth&&0<this.realHeight){AmCharts.VML&&(this.startAlpha=1);var i=this.startDuration,e=this.container,a=this.updateWidth();this.realWidth=a;var h=this.updateHeight();this.realHeight=h;var s=AmCharts.toCoordinate,r=s(this.marginLeft,a),l=s(this.marginRight,a),n=s(this.marginTop,h)+this.getTitleHeight(),d=s(this.marginBottom,h),o,p,u,c=AmCharts.toNumber(this.labelRadius),g=this.measureMaxLabel();g>this.maxLabelWidth&&(g=this.maxLabelWidth);this.labelText&&this.labelsEnabled||(c=g=0);o=void 0===this.pieX?(a-r-l)/2+r:s(this.pieX,this.realWidth);p=void 0===this.pieY?(h-n-d)/2+n:s(this.pieY,h);u=s(this.radius,a,h);u||(a=0<=c?a-r-l-2*g:a-r-l,h=h-n-d,u=Math.min(a,h),h<a&&(u/=1-this.angle/90,u>a&&(u=a)),h=AmCharts.toCoordinate(this.pullOutRadius,u),u=(0<=c?u-1.8*(c+h):u-1.8*h)/2);u<this.minRadius&&(u=this.minRadius);h=s(this.pullOutRadius,u);n=AmCharts.toCoordinate(this.startRadius,u);s=s(this.innerRadius,u);s>=u&&(s=u-1);d=AmCharts.fitToBounds(this.startAngle,0,360);0<this.depth3D&&(d=270<=d?270:90);d-=90;a=u-u*this.angle/90;for(r=0;r<t.length;r++)if(l=t[r],!0!==l.hidden&&0<l.percents){var m=360*l.percents/100,g=Math.sin((d+m/2)/180*Math.PI),b=-Math.cos((d+m/2)/180*Math.PI)*(a/u),C=this.outlineColor;C||(C=l.color);var v=this.alpha;isNaN(l.alpha)||(v=l.alpha);C={fill:l.color,stroke:C,"stroke-width":this.outlineThickness,"stroke-opacity":this.outlineAlpha,"fill-opacity":v};l.url&&(C.cursor="pointer");C=AmCharts.wedge(e,o,p,d,m,u,a,s,this.depth3D,C,this.gradientRatio,l.pattern);this.addEventListeners(C,l);l.startAngle=d;t[r].wedge=C;0<i&&(this.chartCreated||C.setAttr("opacity",this.startAlpha));l.ix=g;l.iy=b;l.wedge=C;l.index=r;if(this.labelsEnabled&&this.labelText&&l.percents>=this.hideLabelsPercent){var A=d+m/2;360<A&&(A-=360);var f=c;isNaN(l.labelRadius)||(f=l.labelRadius);var m=o+g*(u+f),v=p+b*(u+f),R,x=0;if(0<=f){var y;90>=A&&0<=A?(y=0,R="start",x=8):90<=A&&180>A?(y=1,R="start",x=8):180<=A&&270>A?(y=2,R="end",x=-8):270<=A&&360>A&&(y=3,R="end",x=-8);l.labelQuarter=y}else R="middle";var A=this.formatString(this.labelText,l),k=this.labelFunction;k&&(A=k(l,A));k=l.labelColor;k||(k=this.color);A=AmCharts.wrappedText(e,A,k,this.fontFamily,this.fontSize,R,!1,this.maxLabelWidth);A.translate(m+1.5*x,v);A.node.style.pointerEvents="none";l.tx=m+1.5*x;l.ty=v;0<=f?(f=A.getBBox(),k=AmCharts.rect(e,f.width+5,f.height+5,"#FFFFFF",.005),k.translate(m+1.5*x+f.x,v+f.y),l.hitRect=k,C.push(A),C.push(k)):this.freeLabelsSet.push(A);l.label=A;l.tx=m;l.tx2=m+x;l.tx0=o+g*u;l.ty0=p+b*u}m=s+(u-s)/2;l.pulled&&(m+=this.pullOutRadiusReal);l.balloonX=g*m+o;l.balloonY=b*m+p;l.startX=Math.round(g*n);l.startY=Math.round(b*n);l.pullX=Math.round(g*h);l.pullY=Math.round(b*h);this.graphsSet.push(C);(0===l.alpha||0<i&&!this.chartCreated)&&C.hide();d+=360*l.percents/100}0<c&&!this.labelRadiusField&&this.arrangeLabels();this.pieXReal=o;this.pieYReal=p;this.radiusReal=u;this.innerRadiusReal=s;0<c&&this.drawTicks();this.initialStart();this.setDepths()}(t=this.legend)&&t.invalidateSize()}else this.cleanChart();this.dispDUpd();this.chartCreated=!0},setDepths:function(){var t=this.chartData,i;for(i=0;i<t.length;i++){var e=t[i],a=e.wedge,e=e.startAngle;0<=e&&180>e?a.toFront():180<=e&&a.toBack()}},arrangeLabels:function(){var t=this.chartData,i=t.length,e,a;for(a=i-1;0<=a;a--)e=t[a],0!==e.labelQuarter||e.hidden||this.checkOverlapping(a,e,0,!0,0);for(a=0;a<i;a++)e=t[a],1!=e.labelQuarter||e.hidden||this.checkOverlapping(a,e,1,!1,0);for(a=i-1;0<=a;a--)e=t[a],2!=e.labelQuarter||e.hidden||this.checkOverlapping(a,e,2,!0,0);for(a=0;a<i;a++)e=t[a],3!=e.labelQuarter||e.hidden||this.checkOverlapping(a,e,3,!1,0)},checkOverlapping:function(t,i,e,a,h){var s,r,l=this.chartData,n=l.length,d=i.label;if(d){if(!0===a)for(r=t+1;r<n;r++)l[r].labelQuarter==e&&(s=this.checkOverlappingReal(i,l[r],e))&&(r=n);else for(r=t-1;0<=r;r--)l[r].labelQuarter==e&&(s=this.checkOverlappingReal(i,l[r],e))&&(r=0);!0===s&&100>h&&(s=i.ty+3*i.iy,i.ty=s,d.translate(i.tx2,s),i.hitRect&&(d=d.getBBox(),i.hitRect.translate(i.tx2+d.x,s+d.y)),this.checkOverlapping(t,i,e,a,h+1))}},checkOverlappingReal:function(t,i,e){var a=!1,h=t.label,s=i.label;t.labelQuarter!=e||t.hidden||i.hidden||!s||(h=h.getBBox(),e={},e.width=h.width,e.height=h.height,e.y=t.ty,e.x=t.tx,t=s.getBBox(),s={},s.width=t.width,s.height=t.height,s.y=i.ty,s.x=i.tx,AmCharts.hitTest(e,s)&&(a=!0));return a}});
//# sourceMappingURL=pie.map.js